package com.fenghongzhang.module_play.service

import android.app.Service
import android.content.Intent
import android.os.Binder
import android.os.IBinder
import android.util.Log
import com.fenghongzhang.module_play.service.aidl.IMyAidlInterface

private const val TAG = "MyService"
class MyService : Service() {

    companion object{
        const val INT1: Int = 1
        const val INT2: Int = 2
    }

    override fun onBind(intent: Intent): IBinder? {
        return MyBinder()
    }

    inner class MyBinder : IMyAidlInterface.Stub() {
        override fun basicTypes(
            anInt: Int,
            aLong: Long,
            aBoolean: Boolean,
            aFloat: Float,
            aDouble: Double,
            aString: String?
        ) {

        }

        override fun add(a: Int, b: Int): Int {
            return a + b
        }


    }

    override fun onUnbind(intent: Intent?): Boolean {
        Log.i(TAG, "onUnbind: ")
        return super.onUnbind(intent)
    }

    override fun onCreate() {
        super.onCreate()
        Log.i(TAG, "onCreate: ")
    }

    override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
        Log.i(TAG, "onStartCommand: ")
        return START_STICKY
    }

    override fun onDestroy() {
        Log.i(TAG, "onDestroy: ")
        super.onDestroy()
    }
    fun play(){
        Log.i(TAG, "play: ")
        test(MyService.INT1)
    }

    fun test(@AttrParm a:Int){

    }

}